﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.preventionskill
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int psid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(psid);
				}
			}
		}
			
	private void ShowInfo(int psid)
	{
		jnxc.BLL.preventionskill bll=new jnxc.BLL.preventionskill();
		jnxc.Model.preventionskill model=bll.GetModel(psid);
		this.lblpsid.Text=model.psid.ToString();
		this.txthid.Text=model.hid.ToString();
		this.txtpsinfo.Text=model.psinfo;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txthid.Text))
			{
				strErr+="有害生物ID格式错误！\\n";	
			}
			if(this.txtpsinfo.Text.Trim().Length==0)
			{
				strErr+="基本信息不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int psid=int.Parse(this.lblpsid.Text);
			int hid=int.Parse(this.txthid.Text);
			string psinfo=this.txtpsinfo.Text;


			jnxc.Model.preventionskill model=new jnxc.Model.preventionskill();
			model.psid=psid;
			model.hid=hid;
			model.psinfo=psinfo;

			jnxc.BLL.preventionskill bll=new jnxc.BLL.preventionskill();
			bll.Update(model);
			jnxc.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
